﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PWEditor
{
    public partial class NewMap : Form
    {
        private int _rows;
        private int _cols;
        private string _name;

        public NewMap()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder errorString = new StringBuilder();
            bool error = false;

            if (!int.TryParse(this.txtMapCols.Text, out _cols))
            {
                error = true;
                errorString.AppendLine("Please enter a valid amount of columns");
                this.txtMapCols.Focus();
            }

            if (!int.TryParse(this.txtMapRows.Text, out _rows))
            {
                error = true;
                errorString.AppendLine("Please enter a valid amount of rows");
                this.txtMapRows.Focus();
            }

            if (this.txtMapName.Text == string.Empty)
            {
                _name = "Untitled";
            }
            else
            {
                _name = this.txtMapName.Text;
            }

            if (error)
            {
                MessageBox.Show(errorString.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }
        }

        public int Rows
        {
            get { return _rows; }
        }

        public int Cols
        {
            get { return _cols; }
        }

        public string FileName
        {
            get { return _name; }
        }

    }
}
